home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / UTIL / TouchMe 1.1.1.sit / touchMe 1.11 Folder / CW9 PP source / source / Common / LHelpMenu.cp < prev    next >
Text File  |  1996-08-08  |  3KB  |  100 lines

  1. // ==================================================
  2. //    LHelpMenu.cp
  3. //    Copyright (C) 1996 Mizutori Tetsuya, August 4 1996.
  4. // ==================================================
  5. //    All documents are pretty-printed in Geneva 10-point font.
  6.  
  7. #include <Menus.h>
  8. #include <Memory.h>
  9. #include <Balloons.h>
  10.  
  11. #include <LMenuBar.h>
  12. #include <LMenu.h>
  13. #include <PP_Messages.h>
  14.  
  15. //#include "touchMeConstants.h"
  16. #include "LHelpMenu.h"
  17.  
  18.  
  19. // --------------------------------------------------
  20. //        ・ LHelpMenu
  21. // --------------------------------------------------
  22.  
  23. LHelpMenu::LHelpMenu()
  24. {
  25.     OSErr        err;
  26.  
  27.     mMENUid = kHMHelpMenuID;        // -16490
  28.     mNextMenu = nil;                // set by the procedure 'LMenuBar::InstallMenu()'
  29.     mNumCommands = 0;                // the number of items in this menu
  30.     mCommandNums = nil;            // handle to the array of CommandT[*]
  31.     mIsInstalled = false;                // set by the procedure 'LMenuBar::InstallMenu()'
  32.     mUsed = false;                    // set by the procedure 'LEventDispatcher::UpdateMenus()'
  33.     mMacMenuH = nil;                // Macintosh Toolbox menu handle
  34.  
  35.     // Get the help menu handle, which belongs to my application.
  36.     // Do not call ::GetMenuHandle( kHMHelpMenuID ) to get the handle.
  37.     err = ::HMGetHelpMenuHandle( &mMacMenuH );
  38.     // The old MacOS has no HelpMenu, so it returns to do nothing.
  39.     if ( err != noErr )  return;
  40.  
  41.     // Setup a command table of this LHelpMenu object.
  42.     mNumCommands = ::CountMItems( mMacMenuH );
  43.     if ( mNumCommands > 0) {
  44.         Int32    commandsSize = mNumCommands * sizeof(Int32);
  45.         // All the value of (*mCommandNums)[k] are to be 'cmd_Nothing'(= 0).
  46.         mCommandNums = (CommandT **) ::NewHandleClear( commandsSize );
  47.     }    
  48. }
  49.  
  50.  
  51. // --------------------------------------------------
  52. //        ・ ~LHelpMenu
  53. // --------------------------------------------------
  54.  
  55. LHelpMenu::~LHelpMenu()
  56. {
  57. }
  58.  
  59.  
  60. // --------------------------------------------------
  61. //        ・ InstallMenu
  62. // --------------------------------------------------
  63.  
  64. void
  65. LHelpMenu::InstallMenu(
  66.     LMenuBar *inMenuBar )
  67. {
  68.     if ( IsInstalled() ) return;
  69.  
  70.     // If the MacOS has already a Help Menu in the MenuBar,
  71.     // then 'LMenuBar::InstallMenu()' does not do nothing for '::InsertMenu()',
  72.     // but updates the LHelpMenu status of 'mNextMenu' and 'mIsInstalled'.
  73.  
  74. //    LMenuBar *    theMenuBar = (LMenuBar *) LMenuBar::GetCurrentMenuBar();
  75.     inMenuBar->InstallMenu( (LMenu *)this, InstallMenu_AtEnd );
  76. }
  77.  
  78.  
  79. // --------------------------------------------------
  80. //        ・ EnableItem
  81. // --------------------------------------------------
  82.  
  83. void
  84. LHelpMenu::EnableItem()
  85. {
  86.     // The PowerPlant seems to neglect the Help Menu. So you must update
  87.     // the menu status to be enabled after 'LEventDispatcher::UpdateMenus()'.
  88.  
  89.     // Enable the title of the Help Menu in the MenuBar.
  90.     ::EnableItem( mMacMenuH, 0 );
  91.  
  92.     // Enable all the items of the Help Menu.
  93.     for ( short i=1; i<=mNumCommands; i++ ) ::EnableItem( mMacMenuH, i );
  94.  
  95.     // This menu should be considered "used" to be enabled.
  96.     SetUsed( true );
  97. }
  98.  
  99. // end of program
  100.